<?php 
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.inc.php';
//include_once 'inc/tool.ip.inc.php';
$link=connect();

if(is_login($link)){
	skip('index.php','error','你已经登录，请不要重复注册！');
}
if(isset($_POST['submit'])){
	include 'inc/check_register.inc.php';
	$query="insert into member
(username,pwd,truename,qq,email,regtime,ip)
values
(
'{$_POST['username']}',md5('{$_POST['pwd']}'),'{$_POST['truename']}',
{$_POST['qq']},'{$_POST['email']}',NOW(),'{$_SERVER["REMOTE_ADDR"]}')";
	execute($link,$query);
	if(mysqli_affected_rows($link)==1){
		setcookie('tea[username]',$_POST['username']);
		setcookie('tea[pwd]',sha1(md5($_POST['pwd'])));
		skip('index.php','ok','注册成功！');
	}else{
		skip('register.php','eror','注册失败,请重试！');
	}
}

$template['title']='会员注册页';
$template['css']=array('style/public.css','style/register.css');

?>

<?php include 'inc/header.inc.php';?>

	<div id="register" class="auto">
		<h2>欢迎注册成为 武夷茶院会员</h2>
		<form method="POST">
			<label>用户名：<input type="text" name="username" /><span>*用户名不得为空，并且长度不得超过30</span></label>
			<label>密码：<input type="password" name="pwd" /><span>*不得少于六位</span></label>
			<label>确认密码：<input type="password" name="repwd" / /><span>*请输入与上面一致</span></label>
			<label>真实姓名：<input type="text" name="truename" / /><span>*用户名含有禁用字符，请选择其他用户名</span></label>
			<label>QQ：<input type="text" name="qq" / /><span>*用户名含有禁用字符，请选择其他用户名</span></label>
			<label>e-mail：<input type="text" name="email" / /><span>*用户名含有禁用字符，请选择其他用户名</span></label>
			<label>验证码：<input name="vcode" type="text"  /><span>*请输入下方验证码</span></label>
			<img class="vcode" src="show_code.php" />
			<div style="clear:both;"></div>
			<input class="btn" type="submit" name="submit" value="确定注册" />
		</form>
	</div>
	
	<?php include 'inc/footer.inc.php';?>
	